package com.yanqu.road.logic.pb;

import com.yanqu.road.entity.player.UserLTPMainRoleSkin;
import com.yanqu.road.entity.player.UserPatronsSkinBond;
import com.yanqu.road.entity.player.UserSkin;
import com.yanqu.road.pb.skin.SkinProto;

import java.util.Collection;

/**
 * @Author wpj
 * @Date 2020/9/1
 */
public class SkinPb {
    public static SkinProto.UserSkinEntity.Builder getUserSkinEntityMsg(UserSkin userSkin) {
        SkinProto.UserSkinEntity.Builder builder = SkinProto.UserSkinEntity.newBuilder();
        builder.setSkinId(userSkin.getSkinId());
        builder.setLevel(userSkin.getLevel());
        return builder;
    }

    public static SkinProto.UserSkinMsg.Builder getUserSkinMsg(Collection<UserSkin> userSkinList) {
        SkinProto.UserSkinMsg.Builder builder = SkinProto.UserSkinMsg.newBuilder();
        for (UserSkin userSkin : userSkinList) {
            builder.addSkin(getUserSkinEntityMsg(userSkin));
        }
        return builder;
    }

    public static SkinProto.UserLTPMainRoleSkinMsg.Builder getUserLTPMainRoleSkinMsg(Collection<UserLTPMainRoleSkin> userLTPMainRoleSkins) {
        SkinProto.UserLTPMainRoleSkinMsg.Builder builder = SkinProto.UserLTPMainRoleSkinMsg.newBuilder();
        for (UserLTPMainRoleSkin userLTPMainRoleSkin : userLTPMainRoleSkins) {
            builder.addSkin(getUserLTPMainRoleSkinEntityMsg(userLTPMainRoleSkin));
        }
        return builder;
    }

    public static SkinProto.UserLTPMainRoleSkinEntity.Builder getUserLTPMainRoleSkinEntityMsg(UserLTPMainRoleSkin userLTPMainRoleSkin) {
        SkinProto.UserLTPMainRoleSkinEntity.Builder builder = SkinProto.UserLTPMainRoleSkinEntity.newBuilder();
        builder.setSkinId(userLTPMainRoleSkin.getSkinId());
        builder.setAddQualification(userLTPMainRoleSkin.getAddQualification());
        builder.setOverTime(userLTPMainRoleSkin.getOverTime());
        return builder;
    }

    public static SkinProto.UserPatronsSkinBondSyncMsg.Builder parseUserPatronsSkinBondListMsg(Collection<UserPatronsSkinBond> skinBonds) {
        SkinProto.UserPatronsSkinBondSyncMsg.Builder builder = SkinProto.UserPatronsSkinBondSyncMsg.newBuilder();
        for (UserPatronsSkinBond skinBond : skinBonds) {
            builder.addSkinBondInfo(parseUserPatronsSkinBondMsg(skinBond));
        }
        return builder;
    }

    public static SkinProto.UserPatronsSkinBondTemp.Builder parseUserPatronsSkinBondMsg(UserPatronsSkinBond userPatronsSkinBond){
        SkinProto.UserPatronsSkinBondTemp.Builder builder = SkinProto.UserPatronsSkinBondTemp.newBuilder();
        builder.setCombId(userPatronsSkinBond.getCombId());
        builder.setLevel(userPatronsSkinBond.getLevel());
        builder.addAllSkinId(userPatronsSkinBond.getBondIdSet());
        return builder;
    }
}
